package com.grq.mis.model.view;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.beetl.sql.annotation.entity.Table;
import org.beetl.sql.fetch.annotation.Fetch;
import org.beetl.sql.fetch.annotation.FetchSql;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor

@Fetch(level = 2)
@Table(name = "t_permission")
public class PermissionView implements Serializable {

    private Long id;
    private String name;
    private String code;
    private String icon;
    private String url;
    private Long parentId;
    private Boolean isLink;
    private Integer sort;

    @FetchSql("select * from t_permission where parent_id = #{id} order by sort")
    private List<PermissionView> children = new ArrayList<>();

}
